package com.dd.cloud.open.res.api;

import com.dd.cloud.open.enums.ResponseEnum;
import com.dd.cloud.open.exception.ApiException;
import lombok.Data;

/**
 * @author zk
 */
@Data
public class Response<T> {
    /**
     * 状态码
     */
    private Integer code;
    /**
     * 主体信息
     */
    private T body;

    public Response(Integer code, T body) {
        this.code = code;
        this.body = body;
    }

    public Response(ApiException apiException) {
        this.code = apiException.getCode();
        this.body = (T) apiException.getBody();
    }

    public Response(ResponseEnum responseEnum) {
        this.code = responseEnum.getCode();
        this.body = (T) responseEnum.getBody();
    }
}
